Page({

  /**
   * 页面的初始数据
   */
  data: {
    second: 3,
    appid: "",
    page: "",
    conclusion: "",
    is_conclusion: false,
    url: "",
    type: 0,
    isBtn: false
  },
  tmier: null,
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let {
      ret_appid,
      ret_page,
      ret_url,
      ret_type,
      conclusion,
      is_conclusion
    } = JSON.parse(decodeURIComponent(options.succData))
    this.setData({
      appid: ret_appid,
      page: ret_page,
      type: ret_type,
      url: ret_url,
      conclusion,
      is_conclusion
    })
    this.headleNavExternal()
  },


  // 定时跳转跳转
  headleNavExternal() {
    let that = this
    let {
      second
    } = that.data
    this.tmier = setInterval(() => {
      second -= 1
      that.setData({
        second
      })
      if (second === 0) {
        that.headleNav()
      }
    }, 1000)

  },


  //直接跳转
  headleNav() {
    let that = this
    clearInterval(this.tmier)
    let {
      appid,
      page,
      type,
      url
    } = this.data
    if (type == 2) {
      wx.navigateToMiniProgram({
        appId: appid,
        path: page,
        success() {
          that.setData({
            second: 3
          })
        },
        fail() {
          setTimeout(() => {
            wx.switchTab({
              url: '/pages/index/index',
            })
          }, 1500)
        }
      })
    } else if (type == 1) {
      wx.navigateTo({
        url: "/pages/webView/webView?url=" + encodeURIComponent(url),
        success() {
          that.setData({
            second: 3
          })
        },
        fail() {
          setTimeout(() => {
            wx.switchTab({
              url: '/pages/index/index',
            })
          }, 1500)
        }
      })
    } else {
      wx.switchTab({
        url: '/pages/index/index',
      })
    }

  },




  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})